﻿using Microsoft.Extensions.Configuration;
using OConf.NetCore.Common;
using OConf.NetCore.Options;

namespace OConf.NetCore.Static
{
    internal class DownloadConfig
    {
        /// <summary>
        /// 加载配置文件
        /// </summary>
        /// <param name="config"></param>
        internal static void LoadingConfigFile(IConfigurationBuilder config)
        {
            FileCore.CreateDirectory(Cache.saveDicPath);
            List<string> nameSpaces = ConfigNameSpaceOptions.GetNameSpace();

            foreach (var nameSpace in nameSpaces)
            {
                string filePath = Path.Combine(Cache.saveDicPath, $"{nameSpace}.json");

                config.AddJsonFile(filePath, optional: true, reloadOnChange: true);
            }
        }
    }
}
